//---------------------------------------------------------------------------


#pragma hdrstop

#include "TRetarderBrakeStatistics.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

float __fastcall TRetarderBrakeStatistics::GetBrakePercent(void)
{
   return PassTimes < 1 ? 0 : BrakeTimes / PassTimes;
}

void __fastcall TBrakeStatistics::AddItem(unsigned short CutNumber,
														const float AK9,
														const unsigned int PassTimes)
{
	int i;
	TRetarderBrakeStatistics S;
	for (i = 0; i < size(); i++) {
		if (at(i).CutNumber == CutNumber) {
			at(i).BrakeTimes += AK9;
			at(i).PassTimes += PassTimes;
			return;
		}
	}
	S.CutNumber = CutNumber;
	S.BrakeTimes = AK9;
	S.PassTimes = PassTimes;
	push_back(S);
	return;
}

float __fastcall TBrakeStatistics::GetBrakePercent(const unsigned short CutNumber)
{
	int i;
	for (i = 0; i < size(); i++) {
		if (at(i).CutNumber == CutNumber) {
			return at(i).BrakePercent;
		}
	}
	return 0;
}
